#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
ll n,x,y;
const ll MOD = 1e9 + 7;
ll qmi(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b % 2) res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}

int main()
{
    close();
    cin>>n>>x>>y;
    
    n--;
    while(n--)
    {
		ll t=qmi(x,y);
		x=t;
	}
	cout<<x<<'\n';
    return 0;
}
